package com.fe.service.impl;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fe.mapper.PatriarchMapper;
import com.fe.model.Patriarch;
import com.fe.service.PatriarchService;
@Service
public class PatriarchServiceImpl implements PatriarchService {

	@Autowired
	private PatriarchMapper patriarchMapper;
	 
	/**
     * 
     * 方法描述：更新家长个人信息
     * @param request
     * @param map
     * @param patriarch
     * @author ssh
     * @date 2018年8月21日 下午11:38:54
     */
	@Override
	public void update(HttpServletRequest request, Map<String, Object> map, Patriarch patriarch) {
		int result = patriarchMapper.update(patriarch);
		if (result > 0) {
			map.put("message", "更新成功！");
			HttpSession session = request.getSession();
			session.setAttribute("patriarch", patriarchMapper.load(patriarch.getPat_id()));
		}else {
			map.put("message", "更新失败！");
		}
	}

	/**
	 * 
	 * 方法描述：家长修改账号时，判断账号是否已经被使用
	 * @param pat_account
	 * @author ssh
	 * @date 2018年8月22日 下午8:28:39
	 */
	@Override
	public void exictAccount(String pat_account) {
		int result = patriarchMapper.exictAccount(pat_account);
		if (result > 0) {
			throw new RuntimeException("该账号已被使用!");
		}
	}
	
	
    
}
